#include<bits/stdc++.h>
using namespace std;

const int N = 2e5 + 10;
long long a[N];
bool tt[N];
int t, n;
long long ans;

void dfs(int id) {
	if(id == n) {
		long long sum = 0;
		long long c[n];
		int colors[2] = {-1, -1};
		for(int i = 0; i < n; i++) {
			c[i] = 0;
			if(colors[tt[i]] != -1) {
				if(a[colors[tt[i]]] == a[i]) {
					c[i] = a[i];
				}
			}
			sum += c[i];
			colors[tt[i]] = i;
			//cout << c[i] << ' ';
		}
		//cout << sum << endl;
		ans = max(ans, sum);
		return;
	}
	dfs(id + 1);
	tt[id] = true;
	dfs(id + 1);
	tt[id] = false;
}

int main() {
	freopen("color.in", "r", stdin);
	freopen("color.out", "w", stdout);
	cin >> t;
	while(t--) {
		cin >> n;
		bool vis[1000001], flag = true;
		for(int i = 0; i < n; i++) {
			cin >> a[i];
			if(vis[a[i]]) {
				flag = false;
			}
			else {
				vis[a[i]] = true;
			}
		}
		if(flag) {
			cout << 0 << endl;
		}
		else {
			ans = 0;
			dfs(0);
			cout << ans << endl;
		}

	}
	
	return 0;
}
